package com.ivanceras.shared.util;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.ivanceras.shared.bo.Ad_reference;

public class ReferenceLookup {

	public static String getFieldEquiv(String reference){
		if(reference.equals("Account")){
			return "TextBox"; //may not be supported
		}
		else if(reference.equals("Amount")){
			return "TextBox";//will be calculator, with currency support and formatter
		}
		else if(reference.equals("Assignment")){
			return "TextBox"; //may not be supported
		}
		else if(reference.equals("Binary")){
			return "span";//not editable/not viewable
		}
		else if(reference.equals("Button")){
			return "Button";
		}
		else if(reference.equals("Color")){
			return "ColorPicker";//color picker with label
		}
		else if(reference.equals("Costs+Prices")){
			return "TextBox";//may not be supported
		}
		else if(reference.equals("Date")){
			return "Calendar";//gwt calendar
		}
		else if(reference.equals("Date+Time")){
			return "CalendarWithTime";//modified calendar with time
		}
		else if(reference.equals("FileName")){
			return "TextBox";//will be redirected to String
		}
		else if(reference.equals("FilePath")){
			return "TextBox";//will be redirected to String
		}
		else if(reference.equals("ID")){
			return "TextBox";//non-editable
		}
		else if(reference.equals("Image")){
			return "Image";//viewable, cropping may be supported
		}
		else if(reference.equals("Integer")){
			return "TextBox";//will be calculator
		}
		else if(reference.equals("List")){
			return "ListBox";
		}
		else if(reference.equals("Location (Address)")){
			return "TextBox";//will be textbox with Maps
		}
		else if(reference.equals("Locator (WH)")){
			return "TextBox";
		}
		else if(reference.equals("Memo")){
			return "TextArea";//may not be supported
		}
		else if(reference.equals("Number")){
			return "TextBox";//what kind of number? integer or Amount, may be double
		}
		else if(reference.equals("Printer Name")){
			return "TextBox";//will be depreciated with String
		}
		else if(reference.equals("Product Attribute")){
			return "TextBox";//will be depreciated with String
		}
		else if(reference.equals("Quantity")){
			return "TextBox";//Integer or Number may suffice
		}
		else if(reference.equals("RowID")){
			return "TextBox";//non-editable
		}
		else if(reference.equals("Search")){
			return "TextBox";//will be searchbox
		}
		else if(reference.equals("String")){
			return "TextBox";
		}
		else if(reference.equals("Table")){
			return "ListBox";
		}
		else if(reference.equals("Table Direct")){
			return "ListBox";
		}
		else if(reference.equals("Text")){
			return "TextArea"; //or RTA
		}
		else if(reference.equals("Text Long")){
			return "TextArea";
		}
		else if(reference.equals("Time")){
			return "TextBox";
		}
		else if(reference.equals("URL")){
			return "TextBox";
		}
		else if(reference.equals("Yes-No")){
			return "CheckBox";
		}
		else{
			try {
				throw new Exception("Reference is not mapped! Please add the lookup in the code");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	public static Widget getFieldEquiv(Ad_reference reference){
		if(reference == null){
			return new TextBox();
		}
		if(reference.equals("Account")){
			return new TextBox(); //may not be supported
		}
		else if(reference.equals("Amount")){
			return new TextBox();//will be calculator, with currency support and formatter
		}
		else if(reference.equals("Assignment")){
			return new TextBox(); //may not be supported
		}
		else if(reference.equals("Binary")){
			return new HTML();//not editable/not viewable
		}
		else if(reference.equals("Button")){
			return new Button();
		}
		else if(reference.equals("Color")){
			return new TextBox();//color picker with label
		}
		else if(reference.equals("Costs+Prices")){
			return new TextBox();//may not be supported
		}
		else if(reference.equals("Date")){
			return new TextBox();//gwt calendar
		}
		else if(reference.equals("Date+Time")){
			return new TextBox();//modified calendar with time
		}
		else if(reference.equals("FileName")){
			return new TextBox();//will be redirected to String
		}
		else if(reference.equals("FilePath")){
			return new TextBox();//will be redirected to String
		}
		else if(reference.equals("ID")){
			return new TextBox();//non-editable
		}
		else if(reference.equals("Image")){
			return new Image();//viewable, cropping may be supported
		}
		else if(reference.equals("Integer")){
			return new TextBox();//will be calculator
		}
		else if(reference.equals("List")){
			return new ListBox();
		}
		else if(reference.equals("Location (Address)")){
			return new TextBox();//will be textbox with Maps
		}
		else if(reference.equals("Locator (WH)")){
			return new TextBox();
		}
		else if(reference.equals("Memo")){
			return new TextArea();//may not be supported
		}
		else if(reference.equals("Number")){
			return new TextBox();//what kind of number? integer or Amount, may be double
		}
		else if(reference.equals("Printer Name")){
			return new TextBox();//will be depreciated with String
		}
		else if(reference.equals("Product Attribute")){
			return new TextBox();//will be depreciated with String
		}
		else if(reference.equals("Quantity")){
			return new TextBox();//Integer or Number may suffice
		}
		else if(reference.equals("RowID")){
			return new TextBox();//non-editable
		}
		else if(reference.equals("Search")){
			return new TextBox();//will be searchbox
		}
		else if(reference.equals("String")){
			return new TextBox();
		}
		else if(reference.equals("Table")){
			return new ListBox();
		}
		else if(reference.equals("Table Direct")){
			return new ListBox();
		}
		else if(reference.equals("Text")){
			return new TextArea(); //or RTA
		}
		else if(reference.equals("Text Long")){
			return new TextArea();
		}
		else if(reference.equals("Time")){
			return new TextBox();
		}
		else if(reference.equals("URL")){
			return new TextBox();
		}
		else if(reference.equals("Yes-No")){
			return new CheckBox();
		}
		else{
			try {
				throw new Exception("Reference is not mapped! Please add the lookup in the code");
			} catch (Exception e) {
				e.printStackTrace();
			}
			return new TextBox();
		}
	}
}
